package com.eps.controladores;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eps.modelo.TO.ClienteTO;
import com.eps.modelo.TO.UsuarioTO;
import com.eps.modelo.servicios.GestionService;

/**
 * Handles requests for the application home page.
 */
@Controller
public class MovilController {

	@Resource(name="gestionservice")
	 private GestionService gestion_service;
	
	private static final Logger logger = LoggerFactory
			.getLogger(MovilController.class);

	@RequestMapping(value = "/menu", method = RequestMethod.GET)
	public String menu() {
		logger.info("Welcome index!");
		return "menuContent";
	}

	@RequestMapping(value = "/movil/login.htm", method = RequestMethod.GET)
	public @ResponseBody
	/* Map<String, ? extends Object> */UsuarioTO loguearUsuario(
			@RequestParam String usuario, @RequestParam String clave) {
		logger.info(">" + usuario);
		/*
		 * Map<String, Object> myModel = new HashMap<String, Object>();
		 * myModel.put("id", "prueba"); myModel.put("cliente", new
		 * Cliente("001","lui angel")); return myModel;
		 
		List<Cliente> clientes = new ArrayList<Cliente>(1);
		clientes.add(new Cliente("001", "lui angel"));
		clientes.add(new Cliente("002", "aldo renato"));
		clientes.add(new Cliente("003", "ricado hernan"));
		return clientes;
		 */
		return gestion_service.loguearUsuarioMovil(usuario, clave);
	}
	
	@RequestMapping(value = "/movil/cliente.htm", method = RequestMethod.GET)
	public @ResponseBody
	/* Map<String, ? extends Object> */ClienteTO getClientePorCodigo(
			@RequestParam String num_inscrip) {
		logger.info(">" + num_inscrip);
		return gestion_service.getClientePorCodigo(num_inscrip);
	}

}
